From 458052b5ecb466194cd972f06bc72ee945fa92fa Mon Sep 17 00:00:00 2001 From: "jchesterfield@dhcp92.uk.xensource.com" Date: Wed, 30 Aug 2006 11:39:27 +0100 Subject: [PATCH] Block IO safety patch for live migration. Xend checks that VBDs are destroyed before unpausing the domain. --- tools/python/xen/xend/XendCheckpoint.py | 6 ++++-- tools/python/xen/xend/XendDomain.py | 3 ++- tools/python/xen/xend/XendDomainInfo.py | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index 6801f3cd40..9fd3169a9d 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -161,10 +161,12 @@ def restore(xd, fd): if handler.store_mfn is None or handler.console_mfn is None: raise XendError('Could not read store/console MFN') + #Block until src closes connection + os.read(fd, 1) dominfo.unpause() - + dominfo.completeRestore(handler.store_mfn, handler.console_mfn) - + return dominfo except: dominfo.destroy() diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index bbdfd62ab9..af4c474b94 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -431,7 +431,8 @@ class XendDomain: sock.send("receive\n") sock.recv(80) XendCheckpoint.save(sock.fileno(), dominfo, True, live, dst) - + dominfo.testDeviceComplete() + sock.close() def domain_save(self, domid, dst): """Start saving a domain to file. diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index a7a388bbea..48ff0ff291 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1494,6 +1494,21 @@ class XendDomainInfo: if rc != 0: raise XendError("Device of type '%s' refuses migration." % n) + def testDeviceComplete(self): + """ For Block IO migration safety we must ensure that + the device has shutdown correctly, i.e. all blocks are + flushed to disk + """ + while True: + test = 0 + for i in self.getDeviceController('vbd').deviceIDs(): + test = 1 + log.info("Dev %s still active, looping...", i) + time.sleep(0.1) + + if test == 0: + break + def migrateDevices(self, network, dst, step, domName=''): """Notify the devices about migration """ -- 2.30.2